Component({
  data: {
    selected: '',
    color: "#7A7E83",
    selectedColor: "#3cc51f",
    // 涉及到权限的模块
    list: [
      {
        pagePath: "/pages/main/index",
        iconPath: "/tabimage/index.png",
        selectedIconPath: "/tabimage/index_select.png",
        power: "main",
        text: "主页"
      }, {
        pagePath: "/pages/manage/manage",
        iconPath: "/tabimage/manage.png",
        selectedIconPath: "/tabimage/manage_select.png",
        power: "2zhgl",
        text: "智慧管理"
      },
      {
        pagePath: "/pages/qualityControl/index",
        iconPath: "/tabimage/qc.png",
        selectedIconPath: "/tabimage/qc_select.png",
        power: "3zhzk",
        text: "质控管理"
      },
      {
        pagePath: "/pages/waring/index",
        iconPath: "/tabimage/waring.png",
        selectedIconPath: "/tabimage/waring_select.png",
        power: "4znyj",
        text: "智能预警"
      },
      {
        pagePath: "/pages/person/index",
        iconPath: "/tabimage/my.png",
        selectedIconPath: "/tabimage/my_select.png",
        power:"allHave",
        text: "我的"
      }
    ],
    // 渲染模块
    itemMenu:[]
  },
  created(){
  
  },
  attached() {
      let {list} = this.data
      let itemMenu = this.powerJuge(list)
      this.setData({
        itemMenu,
      })
  },
  ready(){
    
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({url})
      // this.setData({
      //   selected: data.index
      // })
      // let self = this;
      // wx.switchTab({
      //   url,
      //   success: function () {
      //     //debugger;
      //     console.log(data.index)
      //     self.setData({
      //       selected: data.index
      //     })
      //   }
      // })

    },
    powerJuge(arr) {
      console.log(arr)
      let powerItem = wx.getStorageSync('power');
      //powerItem = ',' + powerItem + ',';
      let temp = arr.filter((item) => {
        let power =  item.power ;
        //let power = ',' + item.power + ',';
        if (powerItem.indexOf(power) > -1) {
          return item
        }
        if(power == 'allHave'){
          return item
        }
      })
      console.log(temp)
      return temp
    },
  }
})